package Client.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ScrollPaneConstants;

import Server.SocketManager;

public class VentanaSaldo extends JFrame 
{
	public JButton bAtras;
	private JButton bRefresh;
	private JTable saldo;
	private ModeloTabla tablaMaquinas;
	private JTable maquina;
	private ModeloTabla tablaValAct;
	private JTable valAct;
	private int indexActual;
	private SocketManager sm;
	private JScrollPane panelTable;


	public VentanaSaldo(SocketManager socket){
		
		indexActual = -1;
		sm=socket;
		this.setSize(800, 200);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		
		tablaMaquinas = new ModeloTabla();
		maquina = new JTable(tablaMaquinas);
		tablaMaquinas.addColumn("2€");
		tablaMaquinas.addColumn("1€");
		tablaMaquinas.addColumn("50 cent");
		tablaMaquinas.addColumn("20 cent");
		tablaMaquinas.addColumn("10 cent");
		tablaMaquinas.addColumn("5 cent");
		tablaMaquinas.addColumn("Total dinero (no monedas)");
		maquina.setPreferredScrollableViewportSize(new Dimension(300, 200));
		maquina.setFillsViewportHeight(false);
		panelTable = new JScrollPane(maquina);
		panelTable.setVisible(false);
		
		tablaValAct = new ModeloTabla();
		valAct = new JTable(tablaValAct);
		tablaValAct.addColumn("2€");
		tablaValAct.addColumn("1€");
		tablaValAct.addColumn("50 cemt");
		tablaValAct.addColumn("20 cent");
		tablaValAct.addColumn("10 cent");
		tablaValAct.addColumn("5 cent");
		tablaValAct.addColumn("Total dinero (no monedas)");
		valAct.setFillsViewportHeight(false);
		valAct.setPreferredScrollableViewportSize(new Dimension(720, 150));
		JScrollPane panelValAct = new JScrollPane(valAct);
		panelValAct.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
		panelValAct.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		panelValAct.setBorder(BorderFactory.createTitledBorder("Informacion Saldo"));
		
		JPanel propiedadesNotExtended = new JPanel();

		propiedadesNotExtended.add(panelValAct);

		JPanel panelPropiedades = new JPanel(new BorderLayout(5, 5));
		panelPropiedades.add(panelTable, BorderLayout.NORTH);
		panelPropiedades.add(propiedadesNotExtended, BorderLayout.CENTER);
		JPanel panelBPropiedades = new JPanel(new FlowLayout(FlowLayout.CENTER));
		panelPropiedades.add(panelBPropiedades, BorderLayout.SOUTH);
		
		bAtras = new JButton("Atras");
		bRefresh = new JButton("Actualizar Saldo");
		JPanel panelBotones = new JPanel(new FlowLayout(FlowLayout.RIGHT));
		panelBotones.add(bRefresh);
		panelBotones.add(bAtras);
		
		setLayout(new BorderLayout(3, 3));
		add(panelPropiedades, BorderLayout.CENTER);
		add(panelBotones, BorderLayout.SOUTH);
		
		ArrayList<String> saldo = new ArrayList();
		
	}
	


}
